package com.da.boot.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.da.boot.bean.Student;
import com.da.boot.mapper.StudentMapper;
import com.da.boot.service.StudentService;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.stereotype.Service;

/**
 * @author JokerDa.
 * @date 2021/1/27 16:15
 * Description:
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Resource
    private StudentMapper studentMapper;
    private Counter counter;

    public StudentServiceImpl(MeterRegistry meterRegistry) {
        counter = meterRegistry.counter("userQuery.count");
    }

    @Override
    public Student getStudent(int id) {
        counter.increment();
        return studentMapper.getStudent(id);
    }

    @Override
    public List<Student> getAllStudent() {
        return studentMapper.getAllStudent();
    }
}
